﻿using System.Web.Mvc;
using EnetaMvc.ApplicationServices;
using EnetaMvc.Web.Attributes;
using EnetaMvc.Web.Models;

namespace EnetaMvc.Web.Controllers
{
    public class AdminController : Controller
    {
        private readonly INewsService _newsService;

        public AdminController(INewsService newsService)
        {
            _newsService = newsService;
        }

        [EnetaAuthorize(Roles = "Administrator")]
        public ActionResult Index()
        {
            var model = new AdminIndexModel();
            model.PendingArticles = _newsService.ListPendingArticles();
            model.PendingBlogPosts = _newsService.ListPendingBlogPosts(20);
            model.PendingBlogs = _newsService.ListPendingBlogs();
            return View(model);
        }

    }
}
